<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小盒子社区</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
            color: #333;
        }
        
        /* 整体布局 */
        .container {
            width: 90%;
            max-width: 1200px;
            margin: 20px auto;
            padding: 20px;
            background-color: white;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            border-radius: 10px;
        }

        /* 标题样式 */
        h1, h2, h3 {
            color: #333;
        }

        /* 导航栏样式 */
        nav {
            background-color: #333;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 30px;
            border-bottom: 2px solid #444;
        }

        /* 图标样式 */
        .menu-icon {
            font-size: 24px;
            cursor: pointer;
        }

        /* 右侧下拉菜单样式 */
        .dropdown {
            position: relative;
            background-color: #333;
            color: white;
            padding: 10px;
            cursor: pointer;
            border-radius: 5px;
        }

        .dropdown-content {
            display: none;
            background-color: #333;
            color: white;
            position: absolute;
            top: 100%;
            right: 0;
            width: 200px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            border-radius: 5px;
            z-index: 1000;
        }

        .dropdown-content a {
            display: block;
            padding: 10px;
            text-decoration: none;
            color: white;
        }

        .dropdown-content a:hover {
            background-color: #575757;
        }

        .dropdown.open .dropdown-content {
            display: block;
        }

        /* 文件上传样式 */
        form {
            background-color: #f9f9f9;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            margin-bottom: 30px;
        }

        input[type="file"] {
            font-size: 16px;
            padding: 10px;
            border-radius: 5px;
            border: 1px solid #ccc;
            margin-right: 10px;
        }

        button {
            background-color: #333;
            color: white;
            padding: 12px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
        }

        button:hover {
            background-color: #575757;
        }

        /* 文件列表样式 */
        ul {
            list-style: none;
            padding: 0;
        }

        li {
            background-color: #f9f9f9;
            padding: 15px;
            margin: 10px 0;
            border-radius: 5px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        li a {
            color: #333;
            text-decoration: none;
        }

        li a:hover {
            text-decoration: underline;
        }

        /* 返回按钮 */
        a {
            text-decoration: none;
            color: #333;
            font-weight: bold;
            margin-top: 20px;
            display: inline-block;
        }

        a:hover {
            text-decoration: underline;
        }

        /* 响应式布局 */
        @media (max-width: 768px) {
            nav {
                flex-direction: column;
                align-items: flex-start;
            }

            .dropdown-content {
                width: 100%;
            }

            form {
                margin-bottom: 20px;
            }

            ul {
                padding-left: 10px;
            }
        }
    </style>
</head>
<body>
    <nav>
        <div class="menu-icon">小盒子社区</div>
        <div class="dropdown" onclick="toggleDropdown()">
            ☰
            <div class="dropdown-content">
                <a href="">首页</a>
                <a href="/manage_files">上传作品&作品管理</a>
                <a href="https://space.bilibili.com/3493133419546943">bilibili</a>
                <a href="{{ url_for('logout') }}">登出</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <h1>文件管理</h1>
        <h2>欢迎, {{ session['username'] }}</h2>

        <h3>上传新文件</h3>
        <form method="POST" enctype="multipart/form-data">
            <input type="file" name="file" required>
            <button type="submit">上传</button>
        </form>

        <h3>已上传的文件</h3>
        <ul>
            {% for file in files %}
                <li>
                    <div>
                        <a href="{{ url_for('view_file_in_iframe', username=session['username'], filename=file) }}" target="fileViewIframe">{{ file }}</a>
                    </div>
                    <div>
                        <a href="{{ url_for('delete_file', username=session['username'], filename=file) }}" onclick="return confirm('Are you sure you want to delete this file?')">删除</a>
                    </div>
                </li>
            {% endfor %}
        </ul>

        <a href="{{ url_for('index') }}">返回主页</a>
    </div>

    <script>
        function toggleDropdown() {
            const dropdown = document.querySelector('.dropdown');
            dropdown.classList.toggle('open');
        }
    </script>
</body>
</html>
